/*
 * @Author: hfWang
 * @Date: 2022-12-20 10:32:13
 * @LastEditTime: 2022-12-20 18:12:12
 * @Description: file content
 * @FilePath: \rt-libs\src\lfFlowChart\utils\extensionList.ts
 */
import { Menu, MiniMap, SelectionSelect, Snapshot } from '@logicflow/extension';
import baseNodesAndEdges from '../node';

export const useLfConfig = () => {
  /**
   * @desc 插件列表
   */
  const extensionList = [
    SelectionSelect, // 引入框选插件
    MiniMap, // 缩略图
    Snapshot, // 保存为图片
    Menu, // 节点右键菜单
  ];

  /**
   * 自定义节点合线
   */
  const baseNodesAndEdgesList = Object.keys(baseNodesAndEdges).map(
    (key) => baseNodesAndEdges[key],
  );

  /**
   * 获取流程图最终配置
   */
  const getLfConfig = (config: any = {}) => {
    return {
      overlapMode: 1,
      autoWrap: true,
      metaKeyMultipleSelected: true,
      keyboard: {
        enabled: true,
      },
      grid: {
        visible: true,
        size: 10,
      },
      stopScrollGraph: true,
      background: {
        backgroundImage: '#ccc',
        backgroundRepeat: 'repeat',
      },
      ...config,
    };
  };

  return {
    extensionList,
    baseNodesAndEdgesList,
    getLfConfig,
  };
};
